﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FortuneCat.Domain.Abstract;
using FortuneCat.Domain.Entities;

namespace FortuneCat.Domain.Concrete {
    public class EFBalanceRepository : IBalanceRepository {
        private EFDbContext context = new EFDbContext();

        public IQueryable<Balance> Items {
            get { return context.Balances; }
        }

        public void Save(Balance entity) {
            if (entity.Id == 0) {
                context.Balances.Add(entity);
            }
            else {
                context.Entry(entity).State = System.Data.EntityState.Modified;
            }
            context.SaveChanges();
        }

        public void Delete(Balance entity) {
            context.Balances.Remove(entity);
            context.SaveChanges();
        }

    }
}
